package a10_动态规划;

import java.util.Arrays;

/**
 * <p>
 * a42_最长连续递增序列复习4
 * </p>
 *
 * @author flyduck
 * @since 2025/5/7
 */
public class a42_最长连续递增序列复习4 {
    public static void main(String[] args) {
        System.out.println(findLengthOfLCIS(new int[]{1, 3, 5, 4, 7}));
    }
    //连续
    //递增
    //dp[i]：代表以nums[i]为结尾的连续递增序列的最长长度

    //递推公式：
    //if(nums[i] > nums[i-1]){
    //  dp[i] = dp[i-1] + 1
    //}

    //初始化
    public static int findLengthOfLCIS(int[] nums) {
        int[] dp = new int[nums.length];
        Arrays.fill(dp, 1);

        int result = Integer.MIN_VALUE;
        for (int i = 1; i < nums.length; i++) {
            if(nums[i] > nums[i-1]){
                dp[i] = dp[i-1] + 1;
            }
            result = Math.max(result, dp[i]);
        }
        return result == Integer.MIN_VALUE ? 1 : result;
    }
}
